package com.example.demo.services.admin;

import cn.hutool.extra.spring.SpringUtil;
import com.example.demo.models.admin.*;
import com.example.demo.models.user.User;
import gaarason.database.contract.eloquent.Record;

public class UserService {
    private static User.Model userModel;

    static {
        userModel = SpringUtil.getBean(User.Model.class);
    }

    /**
     * 通过学号查询User用户
     * @param number
     * @return
     */
    public static User getUserData(String number) {
        Record<User, Long> record = userModel.newQuery().where(User::getNumber, number).first();
        if (record != null) {
            return record.getEntity();
        } else {
            return null;
        }
    }
}
